<template>
  <div id="app">
    <van-sticky>
      <van-nav-bar
        title="预约记录"
        left-text="返回"
        left-arrow
        @click-left="onClickLeft"
      />
    </van-sticky>
    <div id="main">
      <!-- <vxe-table border="inner" size="mini" :data="data.list">
        <vxe-column type="seq" width="15"></vxe-column>
        <vxe-column :field="'userName'" :title="'咨询人'" />
        <vxe-column :field="'date'" :title="'预约日期'" />
        <vxe-column :field="'startTime'" :title="'开始时间'" />
        <vxe-column :field="'endTime'" :title="'结束时间'" />
        <vxe-column :field="'action'" width="60">
          <template #default="{ row }">
            <van-button size="mini" type="primary" @click="handleClick(row)">
              操作
            </van-button>
          </template>
        </vxe-column>
      </vxe-table> -->
      <Table :header="header" :url="url" @toClick="handleClick"></Table>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { ref, reactive } from 'vue'
import { getRecordOrder } from '/@/views/reserve/api'
import { useRouter } from 'vue-router'
import { Toast } from 'vant'
import Table from '../components/table.vue'

const router = useRouter()

const header = {
  name: 'userName',
  nameKey: '预约人',
  date: 'date',
  dateKey: '预约日期',
  startTime: 'startTime',
  startKey: '发布时间',
  endTime: 'endTime',
  endKey: '预约时间',
}

const url = '/api/blade-appointment/appointment/receive/findTeacherReceiveList'

let data = reactive({
  list: [],
})

const handleClick = (row: any) => {
  if (row.status == 2) {
    Toast('已生成咨询报告!')
    return
  }
  let data: any = {}
  for (let i in row) {
    if (i !== 'id') {
      data[i] = row[i]
    }
  }
  router.push({
    name: 'ReserveReport',
    query: {
      orderId: row.id,
      ...data,
    },
  })
}

const onClickLeft = () => {
  router.push({
    name: 'ReleaseManege',
  })
}
</script>

<style lang="less" scoped>
#main {
  padding-bottom: 40px;
}
</style>
